package com.ln.jvm;

/**
 * <pre>
 *  程序抛出 StackOverflowError 异常
 * </pre>
 *
 * @Author zhangj
 * @Date 2022/7/1 14:59
 */
public class SimpleStackOverflowError {

    private int count = 0;

    /**
     * 没有出口的递归
     */
    public void recursion() {
        count ++;
        recursion();
    }

    public static void main(String[] args) {
        SimpleStackOverflowError testJavaStack = new SimpleStackOverflowError();
        try {
            testJavaStack.recursion();
        } catch (Throwable e) {
            System.out.println("最大栈深度：" + testJavaStack.count);
            e.printStackTrace();
        }
    }


}
